import java.io.*;
import java.util.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.io.file.*;

/**
 * Should log to a file.
 * Because of the strange should-I-really-?-asking behaviour logging
 * to file is disabled. Logging goes to console now.
 */
public class Logger {
    FileConnection fc;
    OutputStream logStream;

    /* Opens a new file for logging. */
    Logger() {
        try {
            // DISABLE fc = (FileConnection)Connector.open("file:///root1/schnitzel.log"); 

			//if( fc.isDirectory() ){
			//	Enumeration names = fc.list();
			//	while( names.hasMoreElements() ){
			//	    String name = (String) names.nextElement();
			//	    System.out.println("one element: " + name);
			//	}
			//}
			
			// DISABLE fc.create();
			// DISABLE logStream = fc.openOutputStream();
			
        } catch (Exception e) {
			System.out.println("I could not create a file for logging because " + e.toString());
			fc = null;
			logStream = null;
		}
    }
	
    public void log(String logMsg) {
		Calendar myCal = Calendar.getInstance();
		logMsg = myCal.getTime() + " Log Message: " + logMsg;

		System.out.println(logMsg);
		/* DISABLE
		if (logStream != null) {
			OutputStreamWriter osw = new OutputStreamWriter(logStream);
			try {
				osw.write(logMsg);
				osw.close();
			} catch (Exception e) {
				System.out.println("Could not write to logfile because " + e.toString());
			}
		}
		*/
    }
	
    public void close() {
		/* DISABLE
		try {
			fc.close();
		} catch (Exception e) {
			System.out.println("Could not close file because " + e.toString());
		}
		*/
    }
}